#!/bin/sh

/bin/mkdir -p /userdata/log/recorder/uconf
/bin/cp /usr/etc/recorder/recorder.uconf /userdata/log/recorder/uconf/

start() {
	printf "Starting recorder service: "
        export LD_PRELOAD=/opt/x1plus/lib/uncurl.so
	start-stop-daemon -S -m -b -p /var/run/recorder_service.pid --exec /usr/bin/recorder -- subscriber
}
stop() {
	printf "Stopping recorder service: "
	start-stop-daemon -K -q -p /var/run/recorder_service.pid
	[ $? = 0 ] && echo "OK" || echo "FAIL"
}
restart() {
	stop
    sleep 5
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	restart
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $?
